package com.seawaterbt.ssm.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.seawaterbt.ssm.entity.*;
import com.seawaterbt.ssm.service.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
@EnableScheduling
public class ShengTest {

    @Autowired
    ShengDatCrewDataService shengDatCrewDataService;

    @Autowired
    ShengDatHeatSourceOutletDataService shengDatHeatSourceOutletDataService;

    @Autowired
    ShengDatHeatStationDataService shengDatHeatStationDataService;

    @Autowired
    ShengDatRoomTempService shengDatRoomTempService;

    @Autowired
    ZDatCrew zDatCrew;
    @Autowired
    ZDatHeatSourceOutlet zDatHeatSourceOutlet;
    @Autowired
    ZDatHeatStation zDatHeatStation;
    @Autowired
    ZDatRoomTemp zDatRoomTemp;
    @Autowired
    ZDatBoiler zDatBoiler;
    @Autowired CzBasHeatcompanyService czBasHeatcompanyService;
    @Autowired ShengBasHeatCompanyService shengBasHeatCompanyService;


    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Scheduled(fixedRate = 30 * 60 * 1000)
    public void dataCrew() {
        System.out.println("开始同步机组到中间库 " + df.format(new Date()));
//        shengDatCrewDataService.sendData();
        zDatCrew.sendData();
    }

    @Scheduled(fixedRate = 30 * 60 * 1000)
    public void dataHeatSourceExit() {
        System.out.println("开始同步热源出口到中间库 " + df.format(new Date()));
//        shengDatHeatSourceOutletDataService.sendData();
        zDatHeatSourceOutlet.sendData();
    }

    @Scheduled(fixedRate = 30 * 60 * 1000)
    public void dataHeatStation() {

        System.out.println("开始同步换热站到中间库 " + df.format(new Date()));
//        shengDatHeatStationDataService.sendData();
        zDatHeatStation.sendData();
    }

    @Scheduled(fixedRate = 30 * 60 * 1000)
    public void dataRoomTemp() {

        System.out.println("开始同步典型测温到中间库 " + df.format(new Date()));
//        shengDatRoomTempService.sendData();
        zDatRoomTemp.sendData();
    }

//    @Scheduled(fixedRate = 20 * 60 * 1000)
    public void BoilerData() {
        System.out.println("开始同步锅炉到中间库 " + df.format(new Date()));
        zDatBoiler.sendData();
    }

    @Scheduled(fixedRate = 2*60*60*1000)
    public void getStationData(){
        System.out.println("开始获取换热站运行数据" + df.format(new Date()));
        zDatHeatStation.getData();
    }

    @Scheduled(fixedRate = 2*60*60*1000)
    public void getSourceData(){
        System.out.println("开始获取热源运行数据"+ df.format(new Date()));
        zDatHeatSourceOutlet.getData();
    }

    public void getHeatCompany(){
        QueryWrapper queryWrapper = new QueryWrapper();
        List<ShengBasHeatcompany> heatcompanyList = shengBasHeatCompanyService.list(queryWrapper);
        for (ShengBasHeatcompany shengBasHeatcompany:heatcompanyList){

        }
    }

}
